<?php include'views/templates/layouts/'.$this->layout.'/header.php'; ?>
<!--Messager-->
<?php
$messager="true";
if($messager!="")
{
    ?>
    <br>
    <div class="alert alert-success">
        <button class="close" data-dismiss="alert">×</button>
        <strong>Success!</strong> The page has been added.
    </div>
<?php
}
    ?>

<!--End Messager-->
    <div class="widget-box">
    <div class="widget-title">

        <h5>List repost</h5>
       <h5> <a href="index.php?controller=product&action=add">Add record!</a></h5>
    </div>
    <div class="widget-content nopadding">
    <table class="table table-bordered table-striped table-hover data-table">
    <thead>
    <tr>
       
        <th>Title</th>
        <th>Image</th>
        <th>Content</th>
        <th>Categoties</th>
        <th>Action</th>
    </tr>
    </thead>
        <tbody>
            <?php
				require_once 'models/carProduct_model.php';
				require_once 'models/product_model.php';
				$catModel = new CatProduct_Model();
                while($row = mysqli_fetch_array($artPro))
                { 
				?>
					<tr class="gradeX">
						
						<td><?php echo $row['title']; ?></td>
						<td><img src="<?php echo SITE_URL.'/media/img/'.$row['image']; ?>" /></td>
						<td><?php echo $row[3]; ?></td>
						<td>
							<?php
							$this->model = new Product_Model();
							$selectCatFromProduct= $this->model->getIdCatProduct($row[0]);
							 while($row1 = mysqli_fetch_array($selectCatFromProduct)){
								/* if($row['id']==$row1[1]){
									$viewCat =  $catModel->viewCat($row1[2]);
									$row2 = mysqli_fetch_row($viewCat); */
									//echo $row1['nameCat'].'<br>'; //exit();
									?>
									<a href="index.php?controller=product&action=listsCat&cat=<?php echo $row1['nameCat']; ?>"><?php echo $row1['nameCat'].'<br>'; ?></a>
									<?php
								}
							mysqli_data_seek($selectCatFromProduct,0);
							?>
						</td>
						<td class="taskOptions">
							<a href="index.php?controller=product&action=view&id=<?php echo $row[0]; ?>" class="tip-top" data-original-title="View"><i class="icon-th"></i></a>
							<a href="index.php?controller=product&action=beforeedit&id=<?php echo $row[0]; ?>" class="tip-top" data-original-title="Edit"><i class="icon-edit"></i></a>
							<a href="index.php?controller=product&action=delete&id=<?php echo $row[0]; ?>" class="tip-top" data-original-title="Delete"><i class="icon-remove"></i></a>
						</td>
					</tr>
            <?php
                }
            ?>
        </tbody>
    </table>
             </div>
            </div>
        </div>
    </div>


<?php include'views/templates/'.$this->layout.'/footer.php'; ?>